

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <script src="/static/jquery.min.js"></script>
    <style>
        .set-color{
            border:2px solid #000000;
        }
    </style>
</head>
<body layadmin-themealias="default">

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body" pad15="">

                    <div class="layui-form" wid100="" lay-filter="">
                        <input type="hidden" name="id" value="{$taginfo.id}" class="layui-input" lay-verify="required" readonly>
                        <div class="layui-form-item">
                            <label class="layui-form-label">标题</label>
                            <div class="layui-input-block">
                                <input type="text" name="title" value="{$taginfo.title}" class="layui-input" lay-verify="required" placeholder="">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">展示色值</label>
                            <div class="layui-input-block">
                                <input type="text" name="color" value="{$taginfo.color}" style="background-color: {$taginfo.color}" placeholder="点击选择颜色" title="点击选择颜色" class="layui-input" id="color-sel-input" lay-verify="required" onclick="set_color()"  readonly="true">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">热度值</label>
                            <div class="layui-input-block">
                                <input type="text" name="point" value="{$taginfo.point}" class="layui-input" lay-verify="required" placeholder="" onkeyup="clearNoNum(this)">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">类型</label>
                            <div class="layui-input-block">
                                <select name="type" lay-verify="required">
                                    {if $taginfo.type == 1}
                                        <option value="1" selected>加热度</option>
                                        <option value="0">减热度</option>
                                    {else /}
                                        <option value="1">加热度</option>
                                        <option value="0" selected>减热度</option>
                                    {/if}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block text-center">
                                <button class="layui-btn" lay-submit="" lay-filter="tag-add">确认保存</button>
                                <button class="layui-btn layui-btn-primary" id="close">取消</button>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/'
        , version: "{:config('other.ui_version')}"
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form','admin', 'tag'], function() {
        var $ = layui.$
            ,form = layui.form
            ,admin = layui.admin;

        var index = parent.layer.getFrameIndex(window.name);

        $('#close').on("click",function () {
            parent.layer.close(index);
        });

        form.on('submit(tag-add)', function(obj){
            //提交
            admin.req({
                url: '/admin/setting/edit_tag_post'
                ,data: obj.field
                ,success: function(res){
                    if (res.code == 0){
                        parent.layer.close(index);
                        parent.layer.msg(res.msg, {icon: 1});
                        parent.layui.table.reload('LAY-tag-manage');
                    }
                }
            });
            return false;
        });
    });

    function set_color() {
        var html = '<div class="layui-colorpicker-main-pre" style="padding-top:0px;align-content: left">';
        html += '<div class="layui-colorpicker-pre" style="width: 40px;height: 24px;" onclick="choose_color(this,\'#0065FF\')"><div style="background:#0065FF"></div></div>';
        html += '<div class="layui-colorpicker-pre" style="width: 40px;height: 24px;" onclick="choose_color(this,\'#2298FF\')"><div style="background:#2298FF"></div></div>';
        html += '<div class="layui-colorpicker-pre" style="width: 40px;height: 24px;" onclick="choose_color(this,\'#00D785\')"><div style="background:#00D785"></div></div>';
        html += '<div class="layui-colorpicker-pre" style="width: 40px;height: 24px;" onclick="choose_color(this,\'#6148FF\')"><div style="background:#6148FF"></div></div>';
        html += '<div class="layui-colorpicker-pre" style="width: 40px;height: 24px;" onclick="choose_color(this,\'#A347FF\')"><div style="background:#A347FF"></div></div>';

        html += '<div class="layui-colorpicker-pre" style="width: 40px;height: 24px;" onclick="choose_color(this,\'#DB74FF\')"><div style="background:#DB74FF"></div></div>';
        html += '<div class="layui-colorpicker-pre" style="width: 40px;height: 24px;" onclick="choose_color(this,\'#FF3B23\')"><div style="background:#FF3B23"></div></div>';
        html += '<div class="layui-colorpicker-pre" style="width: 40px;height: 24px;" onclick="choose_color(this,\'#FF5B00\')"><div style="background:#FF5B00"></div></div>';
        html += '<div class="layui-colorpicker-pre" style="width: 40px;height: 24px;" onclick="choose_color(this,\'#FF8E00\')"><div style="background:#FF8E00"></div></div>';
        html += '<div class="layui-colorpicker-pre" style="width: 40px;height: 24px;" onclick="choose_color(this,\'#FF0063\')"><div style="background:#FF0063"></div></div>';
        html += '<div class="layui-colorpicker-pre" style="width: 40px;height: 24px;" onclick="choose_color(this,\'#8B8B8B\')"><div style="background:#8B8B8B"></div></div>';
        html += '</div>';
        layer.confirm(html,{area: ['326px', '220px'],btn: ['确定'],title:'<strong style="font-size: 13px">请选取颜色</strong>', btn1: function (index) {
                layer.close(index);
            }
        });
    }

    function choose_color(obj, color) {
        $(".layui-colorpicker-main-pre>.layui-colorpicker-pre").each(function(){
            $(this).removeClass('set-color');
        });

        $(obj).addClass('set-color');

        $("#color-sel-input").val(color);
        $("#color-sel-input").css('background-color', color);
    }

    function clearNoNum(obj) {
        obj.value = obj.value.replace(/[^\d]/g, "");
        obj.value = obj.value.replace(/^\./g, "");
    }
</script>
</body>
</html>
